/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OpretMedarbejder.java
 *
 * Created on Dec 6, 2011, 12:18:17 PM
 */
package GUILayer;
import ControlLayer.CtrEmployee;
import ModelLayer.Employee;
 

/**
 *
 * @author R3l4X
 */
public class OpretMedarbejder extends javax.swing.JFrame {
    private static final long serialVersionUID = -3523167882356618543L;
 
    
    /** Creates new form OpretMedarbejder */
    public OpretMedarbejder() {

        initComponents();
        this.setVisible(true);
        
    
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel19 = new javax.swing.JLabel();
        txtMedarbejderOpretNavn = new javax.swing.JTextField();
        txtMedarbejderOpretAdresse = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        txtMedarbejderOpretAnsatDato = new javax.swing.JTextField();
        txtMedarbejderOpretLon = new javax.swing.JTextField();
        btnMedarbejderOpretOpret = new javax.swing.JButton();
        btnMedarbejderOpretAnnuller = new javax.swing.JButton();
        lblOpretMedarbejder = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Opret Medarbejder");

        jLabel19.setText("Navn");

        jLabel20.setText("Adresse");

        jLabel21.setText("Løn");

        jLabel22.setText("Ansættelses Dato");

        btnMedarbejderOpretOpret.setText("Opret");
        btnMedarbejderOpretOpret.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMedarbejderOpretOpretActionPerformed(evt);
            }
        });

        btnMedarbejderOpretAnnuller.setText("Annuller");
        btnMedarbejderOpretAnnuller.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMedarbejderOpretAnnullerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblOpretMedarbejder)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtMedarbejderOpretAdresse)
                                .addComponent(txtMedarbejderOpretNavn, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(txtMedarbejderOpretLon, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtMedarbejderOpretAnsatDato, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnMedarbejderOpretOpret)
                        .addGap(18, 18, 18)
                        .addComponent(btnMedarbejderOpretAnnuller)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(txtMedarbejderOpretNavn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(txtMedarbejderOpretAdresse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMedarbejderOpretLon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMedarbejderOpretAnsatDato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addGap(19, 19, 19)
                .addComponent(lblOpretMedarbejder)
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnMedarbejderOpretOpret)
                    .addComponent(btnMedarbejderOpretAnnuller))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnMedarbejderOpretOpretActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMedarbejderOpretOpretActionPerformed

   
        CtrEmployee ctrEmp = new CtrEmployee();
        Employee empObj = new Employee();
        empObj.setName(txtMedarbejderOpretNavn.getText());
        empObj.setAddress(txtMedarbejderOpretAdresse.getText());
        empObj.setSalary(Double.valueOf(txtMedarbejderOpretLon.getText()));
        empObj.setStartDate(txtMedarbejderOpretAnsatDato.getText());
        ctrEmp.insertNew(empObj);
        lblOpretMedarbejder.setText("Medarbejder er Oprettet med følgende ID : " + ctrEmp.getMaxID());

}//GEN-LAST:event_btnMedarbejderOpretOpretActionPerformed

    private void btnMedarbejderOpretAnnullerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMedarbejderOpretAnnullerActionPerformed

            setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_btnMedarbejderOpretAnnullerActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OpretMedarbejder.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OpretMedarbejder.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OpretMedarbejder.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OpretMedarbejder.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new OpretMedarbejder().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnMedarbejderOpretAnnuller;
    private javax.swing.JButton btnMedarbejderOpretOpret;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel lblOpretMedarbejder;
    private javax.swing.JTextField txtMedarbejderOpretAdresse;
    private javax.swing.JTextField txtMedarbejderOpretAnsatDato;
    private javax.swing.JTextField txtMedarbejderOpretLon;
    private javax.swing.JTextField txtMedarbejderOpretNavn;
    // End of variables declaration//GEN-END:variables
}
